<?php
// +----------------------------------------------------------------------
// | When work is a pleasure, life is a joy!
// +----------------------------------------------------------------------
// | User: ShouKun Liu  |  Email:24147287@qq.com  | Time:2017/1/23 21:10
// +----------------------------------------------------------------------
// | TITLE: 更新表
// +----------------------------------------------------------------------

namespace Common\Model;


use Think\Model;

class OrderUpdateModel extends Model
{

    const CREATE_DATA = 11;//创建数据

    const UPDATE_DATA = 22;//更新数据
    /**
     * 状态列表
     *
     * @var array
     */
    public static $statusList = array(
        '1' => '更新中',
        '2' => '已设置',
        '3' => '已完成',
        '4' => '已关闭',
        '5' => '修改',
    );

    protected $_validate = array(
        array('taobao_pay', 'require', '付款账户错误', '1', self::CREATE_DATA), //
    );

    protected $_auto = array(
        array('create_time', 'time', self::CREATE_DATA, 'function'),
        array('update_time', 'time', self::UPDATE_DATA, 'function'),
    );

    /**
     * 添加更新记录
     * @param $data
     * @return bool|mixed
     */
    public function createOrderUpdate($data)
    {
        if ($this->create($data, self::CREATE_DATA) == false) return false;
        return $this->add();
    }

    /**
     * @param $data
     * @return bool
     */
    public function editOrderUpdate($data)
    {
        if ($this->create($data, self::UPDATE_DATA) == false) return false;
        return $this->where(array('id'=>$data['id']))->save();
    }

}